package com.seecoder.BlueWhale.repository;

import com.seecoder.BlueWhale.enums.CouponStatusEnum;
import com.seecoder.BlueWhale.po.Coupon;
import com.seecoder.BlueWhale.po.CouponGroup;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface CouponRepository extends JpaRepository<Coupon, Integer> {
    List<Coupon> findAllByUserIdAndCouponStatus(int userId, CouponStatusEnum couponStatusEnum);

    Coupon findById(int id);

    @Query("SELECT o FROM Coupon o WHERE o.id = (SELECT MAX(o2.id) FROM Coupon o2)")
    Coupon findWithMaxId();
}